package com.project.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.project.entity.po.Card;

import java.util.List;

/**
 * @ProjectName:
 * @Package:
 * @ClassName:
 * @Author: ZhaoLongShi
 * @CreateDate:
 */
@SuppressWarnings("all")
public interface CardMapper extends BaseMapper<Card> {
    /**
     * 查询所有卡的类别
     *
     * @return
     */
    default List<Card> selectAllCard() {
        QueryWrapper<Card> qw = new QueryWrapper<>();
        qw.lambda().eq(Card::getIsDel, 1);
        return this.selectList(qw);
    }

    /**
     * 检查卡类别是否存在
     *
     * @param cardName
     * @return
     */
    default Long checkCard(String cardName) {
        QueryWrapper<Card> qw = new QueryWrapper<>();
        qw.lambda().eq(Card::getCardName, cardName);
        return this.selectCount(qw);
    }


    /**
     * 删除卡类别
     *
     * @param cardId
     * @return
     */
    int deleteCardById(Long cardId);

    /**
     * 添加卡类别
     *
     * @param card
     * @return
     */
    int addCard(Card card);

}